#coding=utf-8
import datetime
from time import sleep
import stutils
stutils.set_django_environ()
from djstock.shstock.models import *
from scraper import NoPriceTodayError,NoDealError

for s in Share.objects.all():
    print s
    eds = s.exday_set.filter(date__gte='2007-11-01')
    if eds.count() == 0:
        continue
    for e in eds:
        if not e.has_deal():
            print e.date
            try:
                e.deal2db()
            except NoDealError,e:
                print e
                continue
    sleep(0.5)
